//
//  YZChatUtils.h
//  CocoaAsyncSocketClient
//
//  Created by lixiaoyi on 2018/7/5.
//  Copyright © 2018年 lixiaoyi. All rights reserved.
//

/*
 *  聊天工具类
 */

#import <Foundation/Foundation.h>
#import "ImMessage.pbobjc.h"

@interface YZChatUtils : NSObject

/**
 获取时间戳
 
 @return 返回10位的时间戳
 */

+ (NSString *)getTimeInterval;

/**
 获取时间戳

 @return 返回13位时间戳
 */
+ (NSString *)getTimeInterval2;

/**
 时间戳转换成时间

 @param interval 时间戳
 @return 时间
 */
+ (NSString *)timeIntervalToTime:(NSString *)interval;

/**
 把一个日期时间转成聊天格式显示：
 消息大于1周，显示为“2018年7月8日 16:00”
 消息小于1周，大于昨天，显示为“周三 16:00”
 消息小于1周，昨天，显示为“昨天 16：00”
 消息是今天，显示：”16：00“

 @param timeStamp 时间字符戳
 @return 聊天格式显示的字符串
 */
+ (NSString *)showChatTime:(int64_t)timeStamp;


/**
 根据时间戳计算周几

 @param timeStamp 时间戳
 @return 周几
 */
+ (NSString *)weekDayStr:(int64_t)timeStamp;

/**
 获取当前时间

 @return 当前时间
 */
+ (NSString *)currentTime;

/**
 NSData类型转换成十六进制字符串

 @param data nsdata数据
 @return 十六进制字符串
 */
+ (NSString *)convertDataToHexStr:(NSData *)data;

/**
 十六进制转成NSData

 @param hexString 十六进制字符串
 @return NSData类型
 */
+ (NSData*)dataFormHexString:(NSString*)hexString;

/**
 取指定路径下文件数据
 
 @param fileFullPath 文件路径
 @return NSData类型
 */
+ (NSData *)dataFromPath:(NSString *)fileFullPath;

/**
 统计字符串出现次数
 
 @param str 被统计的字符串
 @param subStr 统计字符串
 @return 次数
 */
+ (NSUInteger)cauculateTimer:(NSString *)str
                      subStr:(NSString *)subStr;

+ (ImMessage *)createMessage:(NSString *)protocol
                     version:(NSString *)version
                      userId:(NSString *)userId
                   userToken:(NSString *)userToken
                   messageId:(UInt32)messageId
                 messageType:(NSString *)messageType
                 messageTime:(UInt64)messageTime
                    termType:(NSString *)termType
                    receiver:(NSString *)receiver
                      sender:(NSString *)sender
               ctrlMessageId:(UInt32)ctrlMessageId
                   mediaType:(NSString *)mediaType
                    playload:(NSData *)playload;


+ (ImMessage *)createMessage:(NSString *)protocol
                     version:(NSString *)version
                      userId:(NSString *)userId
                   userToken:(NSString *)userToken
                   messageId:(UInt32)messageId
                 messageType:(NSString *)messageType
                 messageTime:(UInt64)messageTime
                    termType:(NSString *)termType
                    receiver:(NSString *)receiver
                      sender:(NSString *)sender
               ctrlMessageId:(UInt32)ctrlMessageId
                    playload:(NSData *)playload;


+ (ImMessage *)createMessage:(NSString *)protocol
                     version:(NSString *)version
                      userId:(NSString *)userId
                   userToken:(NSString *)userToken
                   messageId:(UInt32)messageId
                 messageType:(NSString *)messageType
                 messageTime:(UInt64)messageTime
                    termType:(NSString *)termType
                    receiver:(NSString *)receiver
                      sender:(NSString *)sender
               ctrlMessageId:(UInt32)ctrlMessageId
                   mediaType:(NSString *)mediaType
                    playload:(NSData *)playload
                      avatar:(NSString *)avatar;

+ (NSString *)distanceTimeWithBeforeTime:(double)beTime;

/**
 判断跟当前日期是否在同一周

 @param date 时间
 @return 是否同一周
 */
+ (BOOL) isSameWeekWithDate:(NSDate *)date;

@end
